-
Notifications
You must be signed in to change notification settings - Fork 243
Conversation
…ome boolean operations. Add AND as default operator.
…s instances of the given model.
Get master up to date
…eating indices; with mapping.
Update master
Added necessary documentation for the new features
Oh... I've used some PHP 7 specific functions... Too soon to require PHP7? |
@thomasjsn sorry for the delay I've been on a personal matter that needs to be addressed. I will review/test it in the weekend |
@ErickTamayo I've made a |
@thomasjsn sure you can include it, I'm planning to review this today and think of new features that we can add to it. |
@ErickTamayo Sure, I'll add it this evening. |
This PR is really VERY huge improvement. Currently working with it. But what if I want only those with 'hello' keyword - and order by 'created_at' field. and this high scoring is not of a big help... that's main issue why I would like to 'disable' default sorting. thanks for ideas |
@huglester What I do is map tags as an array of text or keywords. The I search in that field only: |
Hello @thomasjsn and thanks for letting know. so my initial example was: 'sort' => [
[
'created_at' => [
'order' => 'desc',
],
'id' => [
'order' => 'desc',
],
],
],
'query' => [
'bool' => [
'must' => [
'term' => ['uri' => $query],
],
],
], so basicly sort part is solved now? But I am not sure on how to search the tag now? $articles = \Webas\ProfilesModule\Entities\Profile::elasticSearch('multi_match', 'uri:Some-Url', [
'fields' => ['uri'],
])->get(); But I also need BOOL must stuff Thank you |
I often just do a Project::search('tags:mytag`)->orderBy->('created_at')->get(); You can not include the So either It helps to familiarize oneself a bit with the different search methods that ElasticSearch provides. ElasticSearch is extremely configurable, so it's a bit tricky to write a search method that will suit all needs. You can quite easily write your own trait to tailor the search method exactly like you want. Like I have done for counting, see #42. The you can define the search, filters, ordering and everything like you want it. You will need to dig a bit into mapping the returned ids to the eloquent model. |
I see @thomasjsn Thank you this 42 example. It's good to be able to pass custom queries like so! |
What can we do, to merge this PR in origin package? |
I'm updating homestead right now to test this. So very likely today :)
|
if that matters, I am currently playing this @thomasjsn fork - and not met any problems. VERY HAPPY :) |
I've been using it on my production site for about 2 weeks now |
I am not using in production. but for around a week in development. and very happy user! |
use Laravel\Scout\Builder as ScoutBuilder; | ||
use Laravel\Scout\Searchable; | ||
|
||
trait ElasticSearchable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not totally agree with making a new trait for it. I understand the elasticSearch
method to be able to customize the search but as this is a driver it has to be something that must comply with the current usage of Scout using the Searchable
trait.
We might need to get around the searchableWithin
method, for example a public property in the Model makes more sense here and then in the Engine just make a ternary.
I guess we can have the trait but we need to make it the ElasticsearchEngine
to work out of the box with the Searchable
trait.
@@ -0,0 +1,93 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can have the configuration inside scout.php I would like to have every driver config in the same scout config file.
@@ -44,7 +48,7 @@ public function update($models) | |||
$params['body'][] = [ | |||
'update' => [ | |||
'_id' => $model->getKey(), | |||
'_index' => $this->index, | |||
'_index' => $model->searchableWithin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned in trait, we need to make able to work "out of the box" with the Scout Searchable
trait
Anyone interested, feel free to make the requested changes. For my own need I will be focusing more on Elastic Search specific methods, and less on compliance with searching through Scout. |
I must agree with @thomasjsn Probably some improvements could be made. But the problem with scout is that it is bound to Algolia. you can control lot of stuff in algolia web interface and so on. Elasticsearch is different. There are different versions etc, since this is separate package, I think it can give some improvements over original Scout. And if separe Trait is used, I do not see any harm. Sometimes making tool to 'agnotic' you loose 80% of funtionality and you are left with the 'basics': But who uses elasticsearch, probably has more needs than basic search, and needs more control over search. thank you |
@thomasjsn i have couple of ideas to improve, and questions. at this moment, origin method toSearchableArray() overrides ES mappings in yours mappings() method, while reindexing all. is it ok? although i found, that Scout+ES is incompatible with Eloquent\Model::toArray() method, because if we are store model with it relations in ES, method toArray() anyway reloading model relations from DB. I suggest to somehow override toArray method, with excluding already loaded from ES attributes/relations Discovered, that laravel's method toArray() is not so cool as i expected |
@thomasjsn I can't get the search ordering to work, I'm using the following: Do you know what could cause this? |
@reinierkors please open a issue in the fork, this PR is getting bloated with non-related questions about the pr itself. |
query_string
search